<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>模块管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<script src="../js/global.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery-1.8.2.min.js"></script>
	</head>

	<body>
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
			<legend>系統功能模块维护</legend>
		</fieldset>
		<div class="layui-container">
			<div id="updatePage">
				<form class="layui-form" action="" onsubmit="return false" lay-filter="updateForm">
					<div class="layui-btn-container" style="text-align: right;">
						<button class="layui-btn layui-btn-normal" id="transmit" lay-submit="" lay-filter="updateClass">保存</button>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">试卷名称</label>
						<div class="layui-input-block">
							<input id="testPaperName" type="text" name="testPaperName" class="layui-input">
							<input id="testPaperId" type="hidden" name="testPaperId">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">试卷状态</label>
						<div class="layui-input-block">
							<input id="status" type="text" name="status" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">考试时长</label>
						<div class="layui-input-block">
							<input id="testPaperTime" type="number" name="testPaperTime" lay-verify="required" class="layui-input">
						</div>
					</div>
					<div class="layui-btn-container" style="text-align: center;">
						<table class="layui-hide" id="class_table" lay-filter="test">
					</div>


				</form>
			</div>

		</div> <!--  -->


		</div>
		</div>


	</body>
	<script>
		layui.use(['table', 'form', 'layer', 'laydate', 'upload', 'element'], function() {
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var laydate = layui.laydate;
			var upload = layui.upload;
			var element = layui.element;
			var $ = layui.$;


			table.render({
				elem: '#class_table',
				height: 400,
				url: globalData.examinationServer + '/testPaper/listTestPaperQuestions?testPaperName=' + $("#testPaperName").val(),
				method: "get",
				//headers: {token: globalData.getCurToken()},//设置请求头
				title: "用户表",
				page: true,
				cols: [
					[{
							type: 'checkbox',
							LAY_CHECKED: true,
							LAY_DISABLED: true


						},
						{
							field: 'questionContent',
							title: '题目内容',
							sort: true,
							align: 'center'
						}, {
							field: 'questionCreater',
							title: '出题者',
							sort: true,
							align: 'center'
						}, {
							field: 'questionScore',
							title: '题目分数',
							sort: true,
							align: 'center'
						}, {
							field: 'questionTypeId',
							title: '题目类型',
							templet: '<div>{{questionType(d.questionTypeId)}}</div>'
						}, {
							field: 'questionAnswer',
							title: '正确答案',
							sort: true,
							align: 'center'
						}, {
							field: 'questionAnalysis',
							title: '题目解析'
						}, {
							field: 'questionAnswer',
							title: '正确答案'
						}, {
							title: '操作',
							align: "center",
							toolbar: '#barDemo'
						}
					]
				],
				id: "testReload",
				done: function(res, curr, count) {

				}
			});

			form.on('submit(updateClass)', function(obj) {
				$.ajax({
					type: "put",
					url: globalData.examinationServer + '/testPaper/updateTestPaper',
					data: obj.field, //需要传递到服务端的数据
					dataType: 'json', //服务端响应数据类型
					xhrFields: {
						withCredentials: true
					},
					// beforeSend: function(request) {
					// 	request.setRequestHeader("token", globalData.getCurToken());
					// },
					success: function(res) {
						if (res.code == 0) {
							layer.msg(res.msg, {
								icon: 1,
								time: 2000
							}, function(index) {
								layer.close(index);
								//关闭父窗口并重载
								dkm._close();
								dkm._reload();
							});

						} else {
							layer.msg(res.msg, {
								icon: 2,
								time: 2000
							});
						}
					}



				});
				return false;
			});
		});
	</script>

</html>
